﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using FMSpaceShooter.Screens;
using FMSpaceShooter.ScreenManager;
using FMSpaceShooter.GameObjects.ItemFolder;

namespace FMSpaceShooter.GameObjects
{
    class FirstEnemy : EnemyBase
    {
        public new const string TypeName = "FirstEnemy";
        public const string imageName = "Images/Enemies/firstEnemy";
        

        public FirstEnemy(GameplayScreen screen, Vector2 position)
            :base(screen, imageName, position, 30)
        {

        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (screen.GOM.PlayerOne.IsInPlay)
            {
                var direction = screen.GOM.PlayerOne.Position - position;
                direction.Normalize();
                position += (direction * (float)(gameTime.ElapsedGameTime.TotalSeconds * 100));
                rotation = Util.Tools.VectorToAngle(direction);
            }
            else
            {
                rotation += (float)(1f * gameTime.ElapsedGameTime.TotalSeconds);
            }
        }

        public override void Die()
        {
            base.Die();
            if (screen.Random.Next(20)==4)
                screen.GOM.AddToPlay(new PrimaryBulletBoost(screen,this.position));
        }


    }
}
